#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

bool map[110][110];
int a[2010];
int n,m;
vector<int> res;
bool euler(int vs,int pos)
{
   // printf("dfs: %d %d   res:\n",vs,pos);
    if(pos==m) return false;
    if(pos!=-1)
    {
        bool f=false;
        map[vs][a[pos+1]]=map[a[pos+1]][vs]=false;
        if(euler(a[pos+1],pos+1))
        {
            res.push_back(a[pos+1]);
            f=true;
            //return true;
        }
        else
        {
            map[vs][a[pos+1]]=map[a[pos+1]][vs]=true;
        //printf("back: %d %d<->%d =true\n",vs,vs,a[pos+1]);
            for(int i=1+a[pos+1];i<=n;i++) if(map[vs][i])
            {
                //printf("%d->%d\n",vs,i);
                map[vs][i]=map[i][vs]=false;
                euler(i,-1);
                f=true;
                res.push_back(i);
            }
        }
        return f;
    }
    else
    {
        for(int i=1;i<=n;i++) if(map[vs][i])
        {
            //printf("%d->%d\n",vs,i);
            map[vs][i]=map[i][vs]=false;
            euler(i,-1);
            res.push_back(i);
        }
        return true;
    }
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m+1;i++)cin>>a[i];
    for(int i=1;i<m+1;i++) map[a[i]][a[i-1]]=map[a[i-1]][a[i]]=true;
    if(!euler(a[0],0)) cout<<"No solution"<<endl;
    else
    {
        //if(res.size()!=m) cout<<res.size()<<endl;
        if(res[0]!=a[0]) cout<<"diff: "<<res[0]<<endl;
        cout<<a[0]<<" ";
        for(int i=res.size()-1;i>=0;i--) cout<<res[i]<<" ";
        cout<<endl;
    }
    return 0;
}
/*
11 12
1 4 5 1 2 6 7 2 3 9 8 3 1
10 13
1 4 5 1 2 6 5 7 2 3 8 9 3 1
*/
